package com.snow;

import com.snow.proto.my_wechat.*;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;

public class MyWechatClient {
    public static void main(String[] args) {
        ManagedChannel managedChannel = ManagedChannelBuilder.forAddress("192.168.43.245", 8899).usePlaintext(true).build();

        MyWeChatServiceGrpc.MyWeChatServiceBlockingStub blockingStub = MyWeChatServiceGrpc.newBlockingStub(managedChannel);

        GroupMessages groupMessages = blockingStub.getGroupMessagesByGroupId(
                GroupId.newBuilder().setGroupId(5).build()
        );

        GroupMessage groupMessage = groupMessages.getGroupMessage(0);

        System.out.println(groupMessage.getUserId());
        System.out.println(new String(groupMessage.getContent().toByteArray()));

        managedChannel.shutdown();
    }
}
